package io.renren.controller;

import io.renren.entity.LocaleSaveHuaiAnInputInfo;
import io.renren.entity.Test;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.Map;

@RestController
public class DemoController {

    @GetMapping("/get")
    public Map<String, Object> get(@RequestParam Map<String, Object> map, HttpServletRequest request) {
        System.out.println("get 方法被调用了请求体:" + map);

        Enumeration<String> headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String s = headerNames.nextElement();
            System.out.println("get 方法被调用了请求头:" + s + ":" + request.getHeader(s));
        }
        return map;
    }


    @PostMapping("/post")
    public Map<String, Object> post(@RequestBody Map<String, Object> map, HttpServletRequest request) {
        System.out.println("post 方法被调用了请求体:" + map);
        Enumeration<String> headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String s = headerNames.nextElement();
            System.out.println("post 方法被调用了请求头:" + s + ":" + request.getHeader(s));
            map.put(s,request.getHeader(s));
        }
        return map;
    }

    @PostMapping("/yjgl")
    public LocaleSaveHuaiAnInputInfo yjgl(@RequestBody LocaleSaveHuaiAnInputInfo localeSaveHuaiAnInputInfo) {
        System.out.println("post 方法被调用了请求体:" + localeSaveHuaiAnInputInfo);
        return localeSaveHuaiAnInputInfo;
    }


    @PostMapping("/sjt")
    public Map<String, Object> sjt(@RequestBody Map<String, Object> map) {
        System.out.println("post 方法被调用了请求体:" + map);
        return map;
    }



}
